import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_boost/boost_navigator.dart';
import 'package:flutter_module/common/utils/object_to_any.dart';
import 'package:flutter_module/page/cooperation/case_details_page.dart';
import 'package:flutter_module/page/cooperation/cooperation_home_page.dart';
import 'package:flutter_module/page/cooperation/cooperation_list_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_edit_banner_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_edit_case_show_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_edit_favoured_policy_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_edit_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_edit_service_object_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_edit_service_scope_page.dart';
import 'package:flutter_module/page/service_provider_edit/service_provider_profile_edit_page.dart';

/// Create by kyluzoi
/// Date: 2021-08-20
///
/// Description: 路由文件

Map<String, WidgetBuilder> cooperationRouterMap = {
  // CooperationRouters.HOME: (context) => CooperationHomePage(),
};

Map<String, FlutterBoostRouteFactory> cooperationRouterTable = {
  CooperationRouters.HOME: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return CooperationHomePage(
            params: settings.arguments as Map,
          );
        });
  },
  CooperationRouters.EDIT_SERVICE_OBJECT: (settings, uniqueId) {
    return MaterialPageRoute(
      builder: (context) {
        return ServiceProviderEditServiceObjectPage(
          params: settings.arguments as Map,
        );
      },
      settings: settings,
    );
  },
  CooperationRouters.EDIT_FAVOURED_POLICY: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return ServiceProviderEditFavouredPolicyPage(
            params: settings.arguments as Map,
          );
        });
  },
  CooperationRouters.EDIT_SERVICE_SCOPE: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return ServiceProviderEditServiceScopePage(
            params: settings.arguments as Map,
          );
        });
  },
  CooperationRouters.EDIT_BANNER: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return ServiceProviderEditBannerPage(
            params: settings.arguments as Map,
          );
        });
  },
  CooperationRouters.CASE_DETAILS: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return CaseDetailsPage(
            params: settings.arguments as Map,
          );
        });
  },
  CooperationRouters.EDIT_CASE_SHOW: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return ServiceProviderEditCaseShowPage(
            params: settings.arguments as Map,
          );
        });
  },
  CooperationRouters.edit: (settings, uniqueId) {
    return CupertinoPageRoute(
      builder: (context) {
        return ServiceProviderEditPage();
      },
      settings: settings,
    );
  },
  CooperationRouters.profileEdit: (settings, uniqueId) {
    return CupertinoPageRoute(
      builder: (context) {
        return ServiceProviderProfileEditPage(
          params: object2map(settings.arguments),
        );
      },
      settings: settings,
    );
  },
  CooperationRouters.SERVICE_PROVIDER_LIST: (settings, uniqueId) {
    return PageRouteBuilder<dynamic>(
        settings: settings,
        pageBuilder: (_, __, ___) {
          return CooperationListPage();
        });
  },
};

class CooperationRouters {
  static const String _BASE_PATH = "/cooperation";

  // 合作服务商主页
  static const String HOME = "$_BASE_PATH/service_provider_detail";

  /// 合作服务商编辑页
  static const String edit = '$_BASE_PATH/edit';

  /// 合作服务商简介编辑页
  static const String profileEdit = '$_BASE_PATH/profile_edit';

  //编辑服务对象
  static const String EDIT_SERVICE_OBJECT = "$_BASE_PATH/edit_service_object";

  //编辑优惠政策
  static const String EDIT_FAVOURED_POLICY = "$_BASE_PATH/edit_favoured_policy";

  //服务范围
  static const String EDIT_SERVICE_SCOPE = "$_BASE_PATH/edit_service_scope";

  //banner
  static const String EDIT_BANNER = "$_BASE_PATH/edit_banner";

  // 案例详情
  static const String CASE_DETAILS = "$_BASE_PATH/case_details_page";

  //案例展示编辑
  static const String EDIT_CASE_SHOW = "$_BASE_PATH/edit_case_show";

  // 服务商列表
  static const String SERVICE_PROVIDER_LIST =
      "$_BASE_PATH/service_provider_list";
}
